import { ApiProperty } from '@nestjs/swagger'
import { IsNotEmpty, Matches, MinLength, ValidateIf } from 'class-validator'

export class ModifyPassDto {
  @ApiProperty({ description: '', required: true, default: '' })
  @ValidateIf(item => ![null, undefined, ''].includes(item.newPass))
  @IsNotEmpty({ message: '旧密码必填' })
  @MinLength(8, { message: '旧密码长度不能少于8位' })
  @Matches(/^(?!\d+$).+$/, { message: '旧密码不能为纯数字' })
  readonly oldPass: string

  @ApiProperty({ description: '', required: true, default: '' })
  @ValidateIf(item => ![null, undefined, ''].includes(item.newPass))
  @IsNotEmpty({ message: '新密码必填' })
  @MinLength(8, { message: '新密码长度不能少于8位' })
  @Matches(/^(?!\d+$).+$/, { message: '新密码不能为纯数字' })
  readonly newPass: string

  @ApiProperty({ description: '', required: true, default: '' })
  @ValidateIf(item => ![null, undefined, ''].includes(item.newPass))
  @IsNotEmpty({ message: '确认密码必填' })
  @MinLength(8, { message: '确认密码长度不能少于8位' })
  @Matches(/^(?!\d+$).+$/, { message: '确认密码不能为纯数字' })
  readonly confirmPass: string
}
